<?php
require("regis.php");
if(isset($_REQUEST["add"]))
{
		$obj=new Register;
		//$obj->setSex($_POST["sexType"]);
		$obj->setFirstname($_POST["name"]);
		$obj->setSurname($_POST["surname"]);
		//$obj->setCode($_POST["personalCode"]);
		$obj->setTitle($_POST["title"]);
		$obj->setUsername($_POST["username"]);
		$obj->setPassword($_POST["password"]);
		//$obj->setAddress($_POST["address"]);
		$obj->setEmail($_POST["email"]);
		$filename = explode(".",$_FILES["user_image"]["name"]);
		$ext = $filename[1];
		$obj->setPic($ext);
		
	if($_REQUEST["title"]=="นาย")
		{
			//$obj=new Register;
			$obj->setSex("M");
		}
		else
		{
			$obj->setSex("F");
		}
		$obj->addRecord();
		
}
if(isset($_REQUEST["username"]))
{
	$obj=new Register;
	if($_GET["username"]!="")
	{
		$obj->setUsername($_GET["username"]);
		$obj->validateUser();
	}else{
		echo "";
	}
}

if(isset($_REQUEST["profile"]))
{
		$obj=new Register;
		//$obj->setSex($_POST["sexType"]);
		$obj->setFirstname($_POST["name"]);
		$obj->setSurname($_POST["surname"]);
		$obj->setCode($_POST["personalCode"]);
		$obj->setTitle($_POST["title"]);
		$obj->setUsername($_POST["username"]);
		$obj->setPassword($_POST["password"]);
		$obj->setAddress($_POST["address"]);
		$obj->setEmail($_POST["email"]);
		$filename = explode(".",$_FILES["user_image"]["name"]);
		$ext = $filename[1];
		$obj->setPic($ext);
		
	if($_REQUEST["title"]=="นาย")
		{
			//$obj=new Register;
			$obj->setSex("M");
		}
		else
		{
			$obj->setSex("F");
		}
		//$obj->addRecord();
		$obj->addProfile();
		
}
?>